import { ObjCreate } from "../common/ObjCreate";
import { Language } from "../../../../extend/language/Language";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { RewordItemCellRenderer } from "./RewordItemCellRenderer";
import { TCopy } from "../../../../Message/Db/Tables/TCopy";
import { CopyUtil } from "./CopyUtil";
import { CopyCodeRule } from "../../rules/CopyCodeRule";
import { ItemData } from "../../resource/info/ItemData";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { PageSelecter } from "../common/pageSelect/PageSelecter";
type int = number;
//class CopyGroupRightPanel
    
    export  class CopyGroupRightPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.createChildren();
            return;
        }

        /* internal  */createChildren(): void
        {
            var loc2=0;
            var loc3=null;
            ObjCreate.createBg(0, 0, 136, 430, this, "WindowCenterA");
            ObjCreate.createBg(7, 7, 122, 120, this);
            ObjCreate.createBg(7, 132, 122, 291, this);
            ObjCreate.createLabel(Language.getString(60358), 7, 10, 122, 20, flash.text.TextFormatAlign.CENTER, this, true, 16318411);
            ObjCreate.createLabel(Language.getString(60359), 7, 135, 122, 20, flash.text.TextFormatAlign.CENTER, this, true, 16318411);
            this._descText = ObjCreate.createTextField("", 10, 30, 116, 95, this, new GTextFormat(FontUtil.songtiName, 12, 11661311, null, null, null, null, null, null, null, null, null, 5));
            var loc1=0;
            while (loc1 < 3) 
            {
                loc2 = 0;
                while (loc2 < 6) 
                {
                    loc3 = GlobalClass.getBitmap(ImagesConst.PackItemBg);
                    loc3.x = 9 + loc1 * 39;
                    loc3.y = 156 + loc2 * 39;
                    this.addChild(loc3);
                    ++loc2;
                }
                ++loc1;
            }
            this._rewordItemTile = ObjCreate.createTileList(9, 156, 130, 240, this);
            this._rewordItemTile.rowHeight = 38;
            this._rewordItemTile.columnWidth = 38;
            this._rewordItemTile.horizontalGap = 1;
            this._rewordItemTile.verticalGap = 1;
            this._rewordItemTile.setStyle("cellRenderer", RewordItemCellRenderer);
            addChild(this._rewordItemTile);
            this._pageSelec = ObjCreate.createPageSelecter(40, 400, this);
            this._pageSelec.addEventListener(flash.events.Event.CHANGE, this.onPageChange);
            return;
        }

        public setCopyInfo(arg1: TCopy): void
        {
            var loc4=0;
            var loc1=Language.getStringByParam(60357, arg1.enterMinLevel, CopyUtil.getCopyNumByDay(arg1));
            if (arg1.code == CopyCodeRule.CopyCrossDefenceHard) 
            {
                loc1 = loc1 + ("\n" + Language.getString(60460));
            }
            this._descText.htmlText = loc1;
            this.rewardsItems = [];
            var loc2=arg1.reward.split(",");
            var loc3=0;
            while (loc3 < loc2.length) 
            {
                if (loc2[loc3] != "") 
                {
                    if ((loc4 = Number(loc2[loc3])) != 0) 
                    {
                        this.rewardsItems.push(new ItemData(loc4));
                    }
                }
                ++loc3;
            }
            this.updateRewordItems();
            return;
        }

        /* internal  */onPageChange(arg1: Object /* flash.events.Event */): void
        {
            this.updateRewordItems();
            return;
        }

        /* internal  */updateRewordItems(): void
        {
            this._pageSelec.maxPage = Math.ceil(this.rewardsItems.length / this.pagesize);
            var loc1=(this._pageSelec.currentPage - 1) * this.pagesize;
            var loc2=this._pageSelec.currentPage * this.pagesize > this.rewardsItems.length ? this.rewardsItems.length : this._pageSelec.currentPage * this.pagesize;
            var loc3=this.rewardsItems.slice(loc1, loc2);
            this._rewordItemTile.dataProvider = new DataProvider(loc3);
            return;
        }

        /* internal */ /* var */copy: TCopy;

        /* internal */ /* var */rewardsItems: Array<any>;

        /* internal */ /* var */pagesize: int=18;

        /* internal */ /* var */_descText: Object /* flash.text.TextField */;

        /* internal */ /* var */_rewordItemTile: GTileList;

        /* internal */ /* var */_pageSelec: PageSelecter;
    }
